Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors how Slic keeps connections alive #3670

Merged
merged 8 commits into from
Oct 4, 2023

Conversation

bernardnormier
Copy link
Member

This PR refactors how Slic keeps connections alive.

Fixes #3665.

With this new implementation, Slic keeps connection alive by sending Ping frames from client connections (like before).

The algorithm is now:

  • send a Ping frame idle timeout * 0.6 after the last write even if there is an outstanding pong (= like before, except it's now 0.6 instead of 0.5)
  • send a Ping frame idle timeout * 0.5 after the last read unless there is already an outstanding pong (new)

This PR also refactors the idle timeout decorator and associated tests. They are now 2 separate decorators, one for Ice and one for Slic. This PR didn't change the Ice logic.

Copy link
Member

@externl externl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. See comments.

Copy link
Member

@InsertCreativityHere InsertCreativityHere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sound to me!

// Only client connections send ping frames when idle to keep the server connection alive. The server
// sends back a Pong frame in turn to keep alive the client connection.
_enableIdleTimeoutAndKeepAlive(idleTimeout, IsServer ? null : KeepAlive);
_duplexConnection.Enable(idleTimeout);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to keep IDuplexConnection and then do

if (_duplexConnection is SlicDuplexConnectionDecorator duplexConnectionDecoator)
{
    duplexConnectionDecoator.Enable();
} 

Then we can make SlicDuplexConnectionDecorator timers non-nullable, and keep a single constructor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how this would work.

The difficulty here is the idle timeout is negotiated during connection establishment. At construction time, we don't know if the negotiated idle timeout is good to be infinite or some other value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can pass the idleTimeout I forget to add it there, and that is not the point. The point is to avoid creating this decorator for the Server connections.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the decorator for server connections too. It implements the idle timer.


void SendReadPing()
{
// ReadKeepAlive is no-op unless _pendingPongCount == 0 before the Increment below: we send a Ping only if
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is ReadKeepAlive there is no such operation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. It's the current local function, SendReadPing.

void SendReadPing()
{
// ReadKeepAlive is no-op unless _pendingPongCount == 0 before the Increment below: we send a Ping only if
// there is no outstanding Pong.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is outstanding Pong. correct here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced by pending Pong, like the field name.

@bernardnormier bernardnormier merged commit 2dd4008 into icerpc:main Oct 4, 2023
3 checks passed
@bernardnormier bernardnormier deleted the slic-read-timer branch October 19, 2023 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slic and client-to-server streaming
4 participants